package com.cskaoyan.controller.wxcontroller;

/**
 * @Author Gan
 * @Date 2021/8/7 16:33
 * @Description:
 */
public class MyTest2 {

    public static void main(String[] args) {

    }



    /**
     * 懒加载
     */
    public static class Singleton {

        private Singleton(){}

        private static Singleton singleton = null;

        public Singleton getInstance() {

            synchronized (Singleton.class) {
                if (singleton == null) {
                    singleton = new Singleton();
                }
            }
            return singleton;
        }

    }

    /**
     * 饿汉模式
     */

    public static class Singleton2{

        private Singleton2() {}

        private final static Singleton2 singleton2 = new Singleton2();

        public Singleton2 getstance(){
            return singleton2;
        }
    }
}
